home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume14 / pcomm / part05 < prev    next >
Encoding:
Internet Message Format  |  1988-05-17  |  52.1 KB

  1. Subject:  v14i103:  Dial out and terminal emulator, Part05/06
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: fthood!egray
  7. Posting-number: Volume 14, Issue 103
  8. Archive-name: pcomm/part05
  9.  
  10. #! /bin/sh
  11. # This is a shell archive, meaning:
  12. # 1. Remove everything above the #! /bin/sh line.
  13. # 2. Save the resulting text in a file.
  14. # 3. Execute the file with /bin/sh (not csh) to create:
  15. #    s_axfer.c
  16. #    s_gen.c
  17. #    s_menu.c
  18. #    s_modem.c
  19. #    s_prompt.c
  20. #    s_term.c
  21. #    s_tty.c
  22. #    screen.c
  23. #    st_line.c
  24. #    strings.c
  25. #    terminal.c
  26. #    x_ascii.c
  27. export PATH; PATH=/bin:/usr/bin:$PATH
  28. echo shar: "extracting 's_axfer.c'" '(3885 characters)'
  29. if test -f 's_axfer.c'
  30. then
  31.     echo shar: "will not over-write existing file 's_axfer.c'"
  32. else
  33. sed 's/^X//' << \SHAR_EOF > 's_axfer.c'
  34. X/*
  35. X * Display the ASCII transfer setup, query for changes.  A return code
  36. X * of 1 means something was changed.
  37. X */
  38. X
  39. X#include <stdio.h>
  40. X#include <curses.h>
  41. X#include "misc.h"
  42. X#include "param.h"
  43. X
  44. Xint
  45. Xascii_xfer_setup()
  46. X{
  47. X    WINDOW *x_win, *newwin();
  48. X    int i, ret_code, num;
  49. X    char *ans, *str_prompt(), *menu_prompt(), *strdup();
  50. X    void free_ptr();
  51. X    extern char *v_yes[], *v_cr[], *v_lf[], *v_delay[];
  52. X
  53. X    x_win = newwin(23, 80, 0, 0);
  54. X
  55. X    waddstr(x_win, "----------------------------- ");
  56. X    wattrstr(x_win, A_BOLD, "ASCII Transfer Setup");
  57. X    waddstr(x_win, " -----------------------------");
  58. X    mvwaddstr(x_win, 3, 34, "ASCII UPLOAD");
  59. X    mvwprintw(x_win, 5, 22, "1) Echo locally ........... %s", param->lecho);
  60. X    mvwprintw(x_win, 6, 22, "2) Expand blank lines ..... %s", param->expand);
  61. X    mvwprintw(x_win, 7, 22, "3) CR delay (ms) .......... %d", param->cr_delay);
  62. X    mvwprintw(x_win, 8, 22, "4) Pace the output ........ %s", param->pace);
  63. X    mvwprintw(x_win, 9, 22, "5) CR translation ......... %s", param->cr_up);
  64. X    mvwprintw(x_win, 10, 22, "6) LF translation ......... %s", param->lf_up);
  65. X    mvwaddstr(x_win, 12, 32, "ASCII DOWNLOAD");
  66. X    mvwprintw(x_win, 14, 22, "7) Transfer timeout ....... %d", param->timer);
  67. X    mvwprintw(x_win, 15, 22, "8) CR translation ......... %s", param->cr_dn);
  68. X    mvwprintw(x_win, 16, 22, "9) LF translation ......... %s", param->lf_dn);
  69. X    mvwprintw(x_win, 19, 0, "--------------------------------------------------------------------------------");
  70. X    mvwattrstr(x_win, 20, 0, A_BOLD, "OPTION ==> ");
  71. X    mvwaddstr(x_win, 20, 60, "Press ESC to return");
  72. X    wmove(x_win, 20, 12);
  73. X    touchwin(x_win);
  74. X    wrefresh(x_win);
  75. X                    /* get the option number */
  76. X    ret_code = 0;
  77. X    while ((i = get_num(x_win, 1)) != -1) {
  78. X        switch(i) {
  79. X            case 1:
  80. X                if ((ans = menu_prompt(x_win, 5, 50, "Echo locally", v_yes)) != NULL) {
  81. X                    free_ptr(param->lecho);
  82. X                    param->lecho = strdup(ans);
  83. X                    ret_code++;
  84. X                }
  85. X                break;
  86. X            case 2:
  87. X                if ((ans = menu_prompt(x_win, 6, 50, "Expand blank lines", v_yes)) != NULL) {
  88. X                    free_ptr(param->expand);
  89. X                    param->expand = strdup(ans);
  90. X                    ret_code++;
  91. X                }
  92. X                break;
  93. X            case 3:
  94. X                if ((ans = menu_prompt(x_win, 7, 50, "CR delay (ms)", v_delay)) != NULL) {
  95. X                    param->cr_delay = atoi(ans);
  96. X                    ret_code++;
  97. X                }
  98. X                break;
  99. X            case 4:
  100. X                if ((ans = menu_prompt(x_win, 8, 50, "Pace the output", v_yes)) != NULL) {
  101. X                    free_ptr(param->pace);
  102. X                    param->pace = strdup(ans);
  103. X                    ret_code++;
  104. X                }
  105. X                break;
  106. X            case 5:
  107. X                if ((ans = menu_prompt(x_win, 9, 50, "CR translation (upload)", v_cr)) != NULL) {
  108. X                    free_ptr(param->cr_up);
  109. X                    param->cr_up = strdup(ans);
  110. X                    ret_code++;
  111. X                }
  112. X                break;
  113. X            case 6:
  114. X                if ((ans = menu_prompt(x_win, 10, 50, "LF translation (upload)", v_lf)) != NULL) {
  115. X                    free_ptr(param->lf_up);
  116. X                    param->lf_up = strdup(ans);
  117. X                    ret_code++;
  118. X                }
  119. X                break;
  120. X            case 7:
  121. X                if ((num = num_prompt(x_win, 14, 50, "Transfer timeout", NULL)) != -1) {
  122. X                    if (num > MAX_TIMER || num < MIN_TIMER) {
  123. X                        beep();
  124. X                    /* some reasonable range of values */
  125. X                        if (num < MIN_TIMER)
  126. X                            num = MIN_TIMER;
  127. X                        else
  128. X                            num = MAX_TIMER;
  129. X                        mvwaddstr(x_win, 14, 50, "   ");
  130. X                        wrefresh(x_win);
  131. X                        mvwattrnum(x_win, 14, 50, A_BOLD, num);
  132. X                        wrefresh(x_win);
  133. X                    }
  134. X                    param->timer = num;
  135. X                    ret_code++;
  136. X                }
  137. X                break;
  138. X            case 8:
  139. X                if ((ans = menu_prompt(x_win, 15, 50, "CR translation (download)", v_cr)) != NULL) {
  140. X                    free_ptr(param->cr_dn);
  141. X                    param->cr_dn = strdup(ans);
  142. X                    ret_code++;
  143. X                }
  144. X                break;
  145. X            case 9:
  146. X                if ((ans = menu_prompt(x_win, 16, 50, "LF translation (download)", v_lf)) != NULL) {
  147. X                    free_ptr(param->lf_dn);
  148. X                    param->lf_dn = strdup(ans);
  149. X                    ret_code++;
  150. X                }
  151. X                break;
  152. X            default:
  153. X                beep();
  154. X        }
  155. X        mvwaddch(x_win, 20, 12, ' ');
  156. X        clear_line(x_win, 21, 0, 0);
  157. X        clear_line(x_win, 22, 0, 0);
  158. X        wmove(x_win, 20, 12);
  159. X        wrefresh(x_win);
  160. X    }
  161. X    delwin(x_win);
  162. X    return(ret_code);
  163. X}
  164. SHAR_EOF
  165. if test 3885 -ne "`wc -c < 's_axfer.c'`"
  166. then
  167.     echo shar: "error transmitting 's_axfer.c'" '(should have been 3885 characters)'
  168. fi
  169. fi
  170. echo shar: "extracting 's_gen.c'" '(4267 characters)'
  171. if test -f 's_gen.c'
  172. then
  173.     echo shar: "will not over-write existing file 's_gen.c'"
  174. else
  175. sed 's/^X//' << \SHAR_EOF > 's_gen.c'
  176. X/*
  177. X * Display the general setup, query for changes.  A return code of 1
  178. X * means something was changed.
  179. X */
  180. X
  181. X#include <stdio.h>
  182. X#include <curses.h>
  183. X#include "misc.h"
  184. X#include "param.h"
  185. X
  186. Xint
  187. Xgen_setup()
  188. X{
  189. X    WINDOW *g_win, *newwin();
  190. X    int i, num, ret_code;
  191. X    char c, *ans, *str_prompt(), *menu_prompt(), chr_prompt();
  192. X    char *strdup();
  193. X    void free_ptr();
  194. X    extern char *v_yes[], *v_abort[];
  195. X
  196. X    g_win = newwin(23, 80, 0, 0);
  197. X
  198. X    waddstr(g_win, "--------------------------------- ");
  199. X    wattrstr(g_win, A_BOLD, "General Setup");
  200. X    waddstr(g_win, " --------------------------------");
  201. X    mvwprintw(g_win, 3, 22, "1) Default log file ....... %s", param->logfile);
  202. X    mvwprintw(g_win, 4, 22, "2) Screen dump file ....... %s", param->dumpfile);
  203. X    mvwprintw(g_win, 6, 22, "3) Strip high bit  ........ %s", param->strip);
  204. X    mvwprintw(g_win, 8, 22, "4) Pause character ........ %c", param->pause_char);
  205. X    mvwprintw(g_win, 9, 22, "5) CR character ........... %c", param->cr_char);
  206. X    mvwprintw(g_win, 10, 22, "6) CTRL character ......... %c", param->ctrl_char);
  207. X    mvwprintw(g_win, 11, 22, "7) ESC character .......... %c", param->esc_char);
  208. X    mvwprintw(g_win, 13, 22, "8) Aborted downloads ...... %s", param->abort);
  209. X    mvwprintw(g_win, 15, 22, "9) Connect delay time ..... %d", param->cdelay);
  210. X    mvwprintw(g_win, 16, 21, "10) Pause between redials .. %d", param->pause);
  211. X    mvwprintw(g_win, 19, 0, "--------------------------------------------------------------------------------");
  212. X    mvwattrstr(g_win, 20, 0, A_BOLD, "OPTION ==> ");
  213. X    mvwaddstr(g_win, 20, 60, "Press ESC to return");
  214. X    wmove(g_win, 20, 12);
  215. X    touchwin(g_win);
  216. X    wrefresh(g_win);
  217. X                    /* get the option number */
  218. X    ret_code = 0;
  219. X    while ((i = get_num(g_win, 2)) != -1) {
  220. X        switch(i) {
  221. X            case 1:
  222. X                if ((ans = str_prompt(g_win, 3, 50, "Default log file", NULL)) != NULL) {
  223. X                    free_ptr(param->logfile);
  224. X                    param->logfile = strdup(ans);
  225. X                    ret_code++;
  226. X                }
  227. X                break;
  228. X            case 2:
  229. X                if ((ans = str_prompt(g_win, 4, 50, "Default screen dump file", NULL)) != NULL) {
  230. X                    free_ptr(param->dumpfile);
  231. X                    param->dumpfile = strdup(ans);
  232. X                    ret_code++;
  233. X                }
  234. X                break;
  235. X            case 3:
  236. X                if ((ans = menu_prompt(g_win, 6, 50, "Strip high bit ?", v_yes)) != NULL) {
  237. X                    free_ptr(param->strip);
  238. X                    param->strip = strdup(ans);
  239. X                    ret_code++;
  240. X                }
  241. X                break;
  242. X            case 4:
  243. X                if ((c = chr_prompt(g_win, 8, 50, "Pause character", "1 second")) != NULL) {
  244. X                    param->pause_char = c;
  245. X                    ret_code++;
  246. X                }
  247. X                break;
  248. X            case 5:
  249. X                if ((c = chr_prompt(g_win, 9, 50, "CR character", "(carriage return)")) != NULL) {
  250. X                    param->cr_char = c;
  251. X                    ret_code++;
  252. X                }
  253. X                break;
  254. X            case 6:
  255. X                if ((c = chr_prompt(g_win, 10, 50, "CTRL character", "(control)")) != NULL) {
  256. X                    param->ctrl_char = c;
  257. X                    ret_code++;
  258. X                }
  259. X                break;
  260. X            case 7:
  261. X                if ((c = chr_prompt(g_win, 11, 50, "ESC character", "(escape)")) != NULL) {
  262. X                    param->esc_char = c;
  263. X                    ret_code++;
  264. X                }
  265. X                break;
  266. X            case 8:
  267. X                if ((ans = menu_prompt(g_win, 13, 50, "Aborted downloads", v_abort)) != NULL) {
  268. X                    free_ptr(param->abort);
  269. X                    param->abort = strdup(ans);
  270. X                    ret_code++;
  271. X                }
  272. X                break;
  273. X            case 9:
  274. X                if ((num = num_prompt(g_win, 15, 50, "Connect delay time", "in seconds")) != -1) {
  275. X                    if (num > MAX_CDELAY || num < MIN_CDELAY) {
  276. X                        beep();
  277. X                    /* some reasonable range of values */
  278. X                        if (num < MIN_CDELAY)
  279. X                            num = MIN_CDELAY;
  280. X                        else
  281. X                            num = MAX_CDELAY;
  282. X                        mvwaddstr(g_win, 15, 50, "   ");
  283. X                        wrefresh(g_win);
  284. X                        mvwattrnum(g_win, 15, 50, A_BOLD, num);
  285. X                        wrefresh(g_win);
  286. X                    }
  287. X                    param->cdelay = num;
  288. X                    ret_code++;
  289. X                }
  290. X                break;
  291. X            case 10:
  292. X                if ((num = num_prompt(g_win, 16, 50, "Pause between redials", "in seconds")) != -1) {
  293. X                    if (num > MAX_PAUSE || num < MIN_PAUSE) {
  294. X                        beep();
  295. X                    /* some reasonable range */
  296. X                        if (num < MIN_PAUSE)
  297. X                            num = MIN_PAUSE;
  298. X                        else
  299. X                            num = MAX_PAUSE;
  300. X                        mvwaddstr(g_win, 16, 50, "    ");
  301. X                        wrefresh(g_win);
  302. X                        mvwattrnum(g_win, 16, 50, A_BOLD, num);
  303. X                        wrefresh(g_win);
  304. X                    }
  305. X                    param->pause = num;
  306. X                    ret_code++;
  307. X                }
  308. X                break;
  309. X            default:
  310. X                beep();
  311. X        }
  312. X        mvwaddstr(g_win, 20, 12, "  ");
  313. X        clear_line(g_win, 21, 0, 0);
  314. X        clear_line(g_win, 22, 0, 0);
  315. X        wmove(g_win, 20, 12);
  316. X        wrefresh(g_win);
  317. X    }
  318. X    delwin(g_win);
  319. X    return(ret_code);
  320. X}
  321. SHAR_EOF
  322. if test 4267 -ne "`wc -c < 's_gen.c'`"
  323. then
  324.     echo shar: "error transmitting 's_gen.c'" '(should have been 4267 characters)'
  325. fi
  326. fi
  327. echo shar: "extracting 's_menu.c'" '(2698 characters)'
  328. if test -f 's_menu.c'
  329. then
  330.     echo shar: "will not over-write existing file 's_menu.c'"
  331. else
  332. sed 's/^X//' << \SHAR_EOF > 's_menu.c'
  333. X/*
  334. X * Display the setup menu, prompts for a bunch of other menus.
  335. X */
  336. X
  337. X#include <stdio.h>
  338. X#include <curses.h>
  339. X#include "misc.h"
  340. X
  341. Xvoid
  342. Xsetup_menu(fd)
  343. Xint fd;
  344. X{
  345. X    WINDOW *s_win, *newwin();
  346. X    char *ans, *get_str();
  347. X    int param_flag, modem_flag;
  348. X    void top_line();
  349. X    extern int xmc;
  350. X
  351. X    s_win = newwin(23, 80, 0, 0);
  352. X
  353. X    top_line(s_win);
  354. X    mvwaddstr(s_win, 4, 30, "1) TTY Setup");
  355. X    mvwaddstr(s_win, 6, 30, "2) Modem Setup");
  356. X    mvwaddstr(s_win, 8, 30, "3) Terminal Setup");
  357. X    mvwaddstr(s_win, 10, 30, "4) General Setup");
  358. X    mvwaddstr(s_win, 12, 30, "5) ASCII Transfer Setup");
  359. X    mvwaddstr(s_win, 14, 30, "S) Save setup to disk");
  360. X    mvwaddstr(s_win, 19, 0, "--------------------------------------------------------------------------------");
  361. X    mvwattrstr(s_win, 20, 0, A_BOLD, "OPTION ==> ");
  362. X    mvwaddstr(s_win, 20, 60, "  Press ESC to exit");
  363. X    wmove(s_win, 20, 12);
  364. X    wrefresh(s_win);
  365. X
  366. X    param_flag = 0;
  367. X    modem_flag = 0;
  368. X                    /* get the options */
  369. X    while ((ans = get_str(s_win, 1, "12345Ss", NULL)) != NULL) {
  370. X        if (xmc > 0) {
  371. X            clear_line(s_win, 0, 0, 0);
  372. X            wrefresh(s_win);
  373. X        }
  374. X        switch(*ans) {
  375. X            case '1':
  376. X                if (tty_setup())
  377. X                    modem_flag = 1;
  378. X                break;
  379. X            case '2':
  380. X                if (modem_setup())
  381. X                    modem_flag = 1;
  382. X                break;
  383. X            case '3':
  384. X                if (term_setup())
  385. X                    param_flag = 1;
  386. X                break;
  387. X            case '4':
  388. X                if (gen_setup())
  389. X                    param_flag = 1;
  390. X                break;
  391. X            case '5':
  392. X                if (ascii_xfer_setup())
  393. X                    param_flag = 1;
  394. X                break;
  395. X            case 's':
  396. X            case 'S':
  397. X                if (xmc > 0)
  398. X                    top_line(s_win);
  399. X                if (param_flag || modem_flag) {
  400. X                    wmove(s_win, 22, 27);
  401. X                    /*
  402. X                     * Writes to disk are not critical,
  403. X                     * the changes are made in memory.
  404. X                     */
  405. X                    if (param_flag) {
  406. X                        wattrstr(s_win, A_BLINK, "Updating Parameter File");
  407. X                        wrefresh(s_win);
  408. X                        wait_key(s_win, 3);
  409. X                        if (update_param()) {
  410. X                            touchwin(s_win);
  411. X                            wrefresh(s_win);
  412. X                        }
  413. X                    }
  414. X                    if (modem_flag) {
  415. X                        wattrstr(s_win, A_BLINK, "Updating Modem Database");
  416. X                        wrefresh(s_win);
  417. X                        wait_key(s_win, 3);
  418. X                        if (update_modem()) {
  419. X                            touchwin(s_win);
  420. X                            wrefresh(s_win);
  421. X                        }
  422. X                    }
  423. X                    clear_line(s_win, 22, 27, 0);
  424. X                    wrefresh(s_win);
  425. X                }
  426. X                break;
  427. X            default:
  428. X                beep();
  429. X        }
  430. X        touchwin(s_win);
  431. X        if (xmc > 0)
  432. X            top_line(s_win);
  433. X    
  434. X        mvwaddch(s_win, 20, 12, ' ');
  435. X        wmove(s_win, 20, 12);
  436. X        wrefresh(s_win);
  437. X    }
  438. X    if (fd == -1) {
  439. X        werase(s_win);
  440. X        wrefresh(s_win);
  441. X    }
  442. X    delwin(s_win);
  443. X    return;
  444. X}
  445. X
  446. X/*
  447. X * Put the top line on the window.
  448. X */
  449. X
  450. Xvoid
  451. Xtop_line(win)
  452. XWINDOW *win;
  453. X{
  454. X    clear_line(win, 0, 0, 0);
  455. X    wrefresh(win);
  456. X    waddstr(win, "---------------------------------- ");
  457. X    wattrstr(win, A_BOLD, "Setup Menu");
  458. X    waddstr(win, " ----------------------------------");
  459. X    wrefresh(win);
  460. X    return;
  461. X}
  462. SHAR_EOF
  463. if test 2698 -ne "`wc -c < 's_menu.c'`"
  464. then
  465.     echo shar: "error transmitting 's_menu.c'" '(should have been 2698 characters)'
  466. fi
  467. fi
  468. echo shar: "extracting 's_modem.c'" '(6556 characters)'
  469. if test -f 's_modem.c'
  470. then
  471.     echo shar: "will not over-write existing file 's_modem.c'"
  472. else
  473. sed 's/^X//' << \SHAR_EOF > 's_modem.c'
  474. X/*
  475. X * Display the modem setup, query for changes.  A return code of 1 means
  476. X * something was changed.
  477. X */
  478. X
  479. X#include <stdio.h>
  480. X#include <curses.h>
  481. X#include "misc.h"
  482. X#include "modem.h"
  483. X
  484. Xint
  485. Xmodem_setup()
  486. X{
  487. X    WINDOW *mo_win, *newwin();
  488. X    int i, j, ret_code, modem_prompt();
  489. X    char *ans, *strdup(), *str_prompt();
  490. X    void disp_modem(), free_ptr();
  491. X                    /* the current modem */
  492. X    j = 0;
  493. X    if (modem->m_cur != -1)
  494. X        j = modem->m_cur;
  495. X
  496. X    mo_win = newwin(23, 80, 0, 0);
  497. X
  498. X    waddstr(mo_win, "---------------------------------- ");
  499. X    wattrstr(mo_win, A_BOLD, "Modem Setup");
  500. X    waddstr(mo_win, " ---------------------------------");
  501. X                    /* display the current settings */
  502. X    disp_modem(mo_win, j);
  503. X    mvwprintw(mo_win, 19, 0, "--------------------------------------------------------------------------------");
  504. X    mvwattrstr(mo_win, 20, 0, A_BOLD, "OPTION ==> ");
  505. X    mvwaddstr(mo_win, 20, 60, "Press ESC to return");
  506. X    wmove(mo_win, 20, 12);
  507. X    touchwin(mo_win);
  508. X    wrefresh(mo_win);
  509. X                    /* get the option number */
  510. X    ret_code = 0;
  511. X    while ((i = get_num(mo_win, 2)) != -1) {
  512. X        switch(i) {
  513. X            case 1:
  514. X                j = modem_prompt(mo_win);
  515. X                break;
  516. X            case 2:
  517. X                if ((ans = str_prompt(mo_win, 4, 40, "Modem init string", "sent to the modem once")) != NULL) {
  518. X                    free_ptr(modem->init[j]);
  519. X                    modem->init[j] = strdup(ans);
  520. X                    ret_code++;
  521. X                }
  522. X                break;
  523. X            case 3:
  524. X                if ((ans = str_prompt(mo_win, 5, 40, "Dialing command", NULL)) != NULL) {
  525. X                    free_ptr(modem->dial[j]);
  526. X                    modem->dial[j] = strdup(ans);
  527. X                    ret_code++;
  528. X                }
  529. X                break;
  530. X            case 4:
  531. X                if ((ans = str_prompt(mo_win, 6, 40, "Dialing cmd suffix", "typically the CR character")) != NULL) {
  532. X                    free_ptr(modem->suffix[j]);
  533. X                    modem->suffix[j] = strdup(ans);
  534. X                    ret_code++;
  535. X                }
  536. X                break;
  537. X            case 5:
  538. X                if ((ans = str_prompt(mo_win, 7, 40, "Hangup string", NULL)) != NULL) {
  539. X                    free_ptr(modem->hangup[j]);
  540. X                    modem->hangup[j] = strdup(ans);
  541. X                    ret_code++;
  542. X                }
  543. X                break;
  544. X            case 6:
  545. X                if ((ans = str_prompt(mo_win, 8, 40, "300 baud connect string", NULL)) != NULL) {
  546. X                    free_ptr(modem->con_3[j]);
  547. X                    modem->con_3[j] = strdup(ans);
  548. X                    ret_code++;
  549. X                }
  550. X                break;
  551. X            case 7:
  552. X                if ((ans = str_prompt(mo_win, 9, 40, "1200 baud connect string", NULL)) != NULL) {
  553. X                    free_ptr(modem->con_12[j]);
  554. X                    modem->con_12[j] = strdup(ans);
  555. X                    ret_code++;
  556. X                }
  557. X                break;
  558. X            case 8:
  559. X                if ((ans = str_prompt(mo_win, 10, 40, "2400 baud connect string", NULL)) != NULL) {
  560. X                    free_ptr(modem->con_24[j]);
  561. X                    modem->con_24[j] = strdup(ans);
  562. X                    ret_code++;
  563. X                }
  564. X                break;
  565. X            case 9:
  566. X                if ((ans = str_prompt(mo_win, 11, 40, "4800 baud connect string", NULL)) != NULL) {
  567. X                    free_ptr(modem->con_48[j]);
  568. X                    modem->con_48[j] = strdup(ans);
  569. X                    ret_code++;
  570. X                }
  571. X                break;
  572. X            case 10:
  573. X                if ((ans = str_prompt(mo_win, 12, 40, "9600 baud connect string", NULL)) != NULL) {
  574. X                    free_ptr(modem->con_96[j]);
  575. X                    modem->con_96[j] = strdup(ans);
  576. X                    ret_code++;
  577. X                }
  578. X                break;
  579. X            case 11:
  580. X                if ((ans = str_prompt(mo_win, 13, 40, "19200 baud connect string", NULL)) != NULL) {
  581. X                    free_ptr(modem->con_192[j]);
  582. X                    modem->con_192[j] = strdup(ans);
  583. X                    ret_code++;
  584. X                }
  585. X                break;
  586. X            case 12:
  587. X                if ((ans = str_prompt(mo_win, 14, 40, "No connect string 1", NULL)) != NULL) {
  588. X                    free_ptr(modem->no_con1[j]);
  589. X                    modem->no_con1[j] = strdup(ans);
  590. X                    ret_code++;
  591. X                }
  592. X                break;
  593. X            case 13:
  594. X                if ((ans = str_prompt(mo_win, 15, 40, "No connect string 2", NULL)) != NULL) {
  595. X                    free_ptr(modem->no_con2[j]);
  596. X                    modem->no_con2[j] = strdup(ans);
  597. X                    ret_code++;
  598. X                }
  599. X                break;
  600. X            case 14:
  601. X                if ((ans = str_prompt(mo_win, 16, 40, "No connect string 3", NULL)) != NULL) {
  602. X                    free_ptr(modem->no_con3[j]);
  603. X                    modem->no_con3[j] = strdup(ans);
  604. X                    ret_code++;
  605. X                }
  606. X                break;
  607. X            case 15:
  608. X                if ((ans = str_prompt(mo_win, 17, 40, "No connect string 4", NULL)) != NULL) {
  609. X                    free_ptr(modem->no_con4[j]);
  610. X                    modem->no_con4[j] = strdup(ans);
  611. X                    ret_code++;
  612. X                }
  613. X                break;
  614. X            default:
  615. X                beep();
  616. X        }
  617. X                    /* clear the previous prompts */
  618. X        mvwaddstr(mo_win, 20, 12, "   ");
  619. X        clear_line(mo_win, 21, 0, 0);
  620. X        clear_line(mo_win, 22, 0, 0);
  621. X        wmove(mo_win, 20, 12);
  622. X        wrefresh(mo_win);
  623. X    }
  624. X    delwin(mo_win);
  625. X    return(ret_code);
  626. X}
  627. X
  628. X/*
  629. X * Prompts for the modem name.  The user selects the currently showing
  630. X * choice by hitting a carriage return.  Returns the modem entry number.
  631. X * DOES NOT change the value of modem->m_cur.
  632. X */
  633. X
  634. Xint
  635. Xmodem_prompt(win)
  636. XWINDOW *win;
  637. X{
  638. X    char ans;
  639. X    int i;
  640. X                    /* print prompt lines */
  641. X    mvwaddstr(win, 22, 0, "Press any key to change, or <CR> to accept");
  642. X    mvwaddstr(win, 21, 0, "Modem name: ");
  643. X                    /* show current choice */
  644. X    i = 0;
  645. X    if (modem->m_cur != -1)
  646. X        i = modem->m_cur;
  647. X    mvwprintw(win, 21, 12, "%-30.30s", modem->mname[i]);
  648. X    wmove(win, 21, 12);
  649. X    wrefresh(win);
  650. X                    /* show the choices one at a time */
  651. X    while ((ans = wgetch(win)) != '\r') {
  652. X        i++;
  653. X        if (*modem->mname[i] == NULL)
  654. X            i = 0;
  655. X        if (ans == 27)
  656. X            return(0);
  657. X        mvwprintw(win, 21, 12, "%-30.30s", modem->mname[i]);
  658. X        wmove(win, 21, 12);
  659. X        wrefresh(win);
  660. X    }
  661. X                    /* display the new values */
  662. X    disp_modem(win, i);
  663. X                    /* display the name in bold */
  664. X    clear_line(win, 2, 40, 0);
  665. X    wrefresh(win);
  666. X    mvwattrstr(win, 2, 40, A_BOLD, modem->mname[i]);
  667. X
  668. X    return(i);
  669. X}
  670. X
  671. X/*
  672. X * Show the current settings for the given modem entry number.
  673. X */
  674. X
  675. Xvoid
  676. Xdisp_modem(w, i)
  677. XWINDOW *w;
  678. Xint i;
  679. X{
  680. X    mvwprintw(w, 2, 12, "1) Modem name ............. %-39.39s", modem->mname[i]);
  681. X    mvwprintw(w, 4, 12, "2) Modem init string ...... %-39.39s", modem->init[i]);
  682. X    mvwprintw(w, 5, 12, "3) Dialing command ........ %-39.39s", modem->dial[i]);
  683. X    mvwprintw(w, 6, 12, "4) Dialing cmd suffix ..... %-39.39s", modem->suffix[i]);
  684. X    mvwprintw(w, 7, 12, "5) Hangup string .......... %-39.39s", modem->hangup[i]);
  685. X    mvwprintw(w, 8, 12, "6) 300 baud connect ....... %-39.39s", modem->con_3[i]);
  686. X    mvwprintw(w, 9, 12, "7) 1200 baud connect ...... %-39.39s", modem->con_12[i]);
  687. X    mvwprintw(w, 10, 12, "8) 2400 baud connect ...... %-39.39s", modem->con_24[i]);
  688. X    mvwprintw(w, 11, 12, "9) 4800 baud connect ...... %-39.39s", modem->con_48[i]);
  689. X    mvwprintw(w, 12, 11, "10) 9600 baud connect ...... %-39.39s", modem->con_96[i]);
  690. X    mvwprintw(w, 13, 11, "11) 19200 baud connect ..... %-39.39s", modem->con_192[i]);
  691. X    mvwprintw(w, 14, 11, "12) No connect string 1 .... %-39.39s", modem->no_con1[i]);
  692. X    mvwprintw(w, 15, 11, "13) No connect string 2 .... %-39.39s", modem->no_con2[i]);
  693. X    mvwprintw(w, 16, 11, "14) No connect string 3 .... %-39.39s", modem->no_con3[i]);
  694. X    mvwprintw(w, 17, 11, "15) No connect string 4 .... %-39.39s", modem->no_con4[i]);
  695. X    return;
  696. X}
  697. SHAR_EOF
  698. if test 6556 -ne "`wc -c < 's_modem.c'`"
  699. then
  700.     echo shar: "error transmitting 's_modem.c'" '(should have been 6556 characters)'
  701. fi
  702. fi
  703. echo shar: "extracting 's_prompt.c'" '(3369 characters)'
  704. if test -f 's_prompt.c'
  705. then
  706.     echo shar: "will not over-write existing file 's_prompt.c'"
  707. else
  708. sed 's/^X//' << \SHAR_EOF > 's_prompt.c'
  709. X/*
  710. X * Prompting routines used in the setup menus.
  711. X */
  712. X
  713. X#include <stdio.h>
  714. X#include <curses.h>
  715. X#include "misc.h"
  716. X
  717. X/*
  718. X * Prompt for a string at line 21 (with optional line 22 for additional
  719. X * information).  Display the new string in bold at its original location
  720. X * in the menu.  Used in virtually all of the *_setup() routines.
  721. X */
  722. X
  723. Xchar *
  724. Xstr_prompt(win, y, x, p1, p2)
  725. XWINDOW *win;
  726. Xint y, x;
  727. Xchar *p1, *p2;
  728. X{
  729. X    char *ans, *get_str();
  730. X    extern char *null_ptr;
  731. X                    /* print first prompt last */
  732. X    mvwaddstr(win, 22, 0, p2);
  733. X    mvwaddstr(win, 21, 0, p1);
  734. X    waddstr(win, ": ");
  735. X    wrefresh(win);
  736. X
  737. X    if ((ans = get_str(win, 39, NULL, NULL)) == NULL)
  738. X        return(NULL);
  739. X                    /* check the value */
  740. X    if (!strcmp(ans, " "))
  741. X        ans = null_ptr;
  742. X                    /* display the value in bold */
  743. X    clear_line(win, y, x, 0);
  744. X    wattrstr(win, A_BOLD, ans);
  745. X
  746. X    return(ans);
  747. X}
  748. X
  749. X/*
  750. X * Same as above, except we return a single character.
  751. X */
  752. X
  753. Xchar
  754. Xchr_prompt(win, y, x, p1, p2)
  755. XWINDOW *win;
  756. Xint y, x;
  757. Xchar *p1, *p2;
  758. X{
  759. X    char *ans, *get_str();
  760. X                    /* print first prompt last */
  761. X    mvwaddstr(win, 22, 0, p2);
  762. X    mvwaddstr(win, 21, 0, p1);
  763. X    waddstr(win, ": ");
  764. X    wrefresh(win);
  765. X
  766. X    if ((ans = get_str(win, 1, NULL, NULL)) == NULL)
  767. X        return(NULL);
  768. X                    /* display the value in bold */
  769. X    mvwaddstr(win, y, x, "  ");
  770. X    wrefresh(win);
  771. X    mvwattrstr(win, y, x, A_BOLD, ans);
  772. X
  773. X    return(*ans);
  774. X}
  775. X
  776. X/*
  777. X * Same as above, except that it prompts for a three digit number.
  778. X */
  779. X
  780. Xint
  781. Xnum_prompt(win, y, x, p1, p2)
  782. XWINDOW *win;
  783. Xint y, x;
  784. Xchar *p1, *p2;
  785. X{
  786. X    int i, get_num();
  787. X                    /* print first prompt last */
  788. X    mvwaddstr(win, 22, 0, p2);
  789. X    mvwaddstr(win, 21, 0, p1);
  790. X    waddstr(win, ": ");
  791. X    wrefresh(win);
  792. X
  793. X    if ((i = get_num(win, 3)) == -1)
  794. X        return(-1);
  795. X                    /* display the value in bold */
  796. X    mvwaddstr(win, y, x, "    ");
  797. X    wrefresh(win);
  798. X    mvwattrnum(win, y, x, A_BOLD, i);
  799. X                    /* return the number */
  800. X    return(i);
  801. X}
  802. X
  803. X/*
  804. X * Prompts for a selection from a menu.  We display the prompt lines,
  805. X * and show the choices one at a time.  The user selects the currently
  806. X * showing choice by hitting a carriage return.  Unlike the similar
  807. X * routines in d_prompt(), the first choice shown is not necessarily
  808. X * the current.
  809. X */
  810. X
  811. Xchar *v_yes[3] = {"YES", "NO", NULL};
  812. Xchar *v_crio[3] = {"CR", "CR/LF", NULL};
  813. Xchar *v_cr[4] = {"NONE", "STRIP", "ADD LF", NULL};
  814. Xchar *v_lf[4] = {"NONE", "STRIP", "ADD CR", NULL};
  815. Xchar *v_abort[3] = {"KEEP", "DELETE", NULL};
  816. Xchar *v_duplex[3] = {"FULL", "HALF", NULL};
  817. Xchar *v_flow[3] = {"NONE", "XON/XOFF", NULL};
  818. Xchar *v_baud[7] = {"300", "1200", "2400", "4800", "9600", "19200", NULL};
  819. Xchar *v_delay[4] = {"0", "100", "150", NULL};
  820. X
  821. Xchar *
  822. Xmenu_prompt(win, y, x, p, menu)
  823. XWINDOW *win;
  824. Xint y, x;
  825. Xchar *p, *menu[];
  826. X{
  827. X    char ans;
  828. X    int i, cy, cx;
  829. X                    /* print first prompt last */
  830. X    mvwaddstr(win, 22, 0, "Press any key to change, or <CR> to accept");
  831. X    mvwaddstr(win, 21, 0, p);
  832. X    waddstr(win, ": ");
  833. X                    /* show first choice */
  834. X    i = 0;
  835. X    getyx(win, cy, cx);
  836. X    mvwprintw(win, cy, cx, "%-30.30s", menu[i]);
  837. X    wmove(win, cy, cx);
  838. X    wrefresh(win);
  839. X                    /* show the choices one at a time */
  840. X    while ((ans = wgetch(win)) != '\r') {
  841. X        i++;
  842. X        if (*menu[i] == NULL)
  843. X            i = 0;
  844. X        if (ans == 27)
  845. X            return(NULL);
  846. X        mvwprintw(win, cy, cx, "%-30.30s", menu[i]);
  847. X        wmove(win, cy, cx);
  848. X        wrefresh(win);
  849. X    }
  850. X                    /* display the value in bold */
  851. X    clear_line(win, y, x, 0);
  852. X    wattrstr(win, A_BOLD, menu[i]);
  853. X                    /* return the value */
  854. X    return(menu[i]);
  855. X}
  856. SHAR_EOF
  857. if test 3369 -ne "`wc -c < 's_prompt.c'`"
  858. then
  859.     echo shar: "error transmitting 's_prompt.c'" '(should have been 3369 characters)'
  860. fi
  861. fi
  862. echo shar: "extracting 's_term.c'" '(2743 characters)'
  863. if test -f 's_term.c'
  864. then
  865.     echo shar: "will not over-write existing file 's_term.c'"
  866. else
  867. sed 's/^X//' << \SHAR_EOF > 's_term.c'
  868. X/*
  869. X * Display the terminal setup, query for changes.  A return code of 1
  870. X * means something was changed.
  871. X */
  872. X
  873. X#include <stdio.h>
  874. X#include <curses.h>
  875. X#include "misc.h"
  876. X#include "param.h"
  877. X
  878. Xint
  879. Xterm_setup()
  880. X{
  881. X    WINDOW *t_win, *newwin();
  882. X    int i, num, ret_code;
  883. X    char *ans, *strdup(), *str_prompt(), *menu_prompt();
  884. X    void free_ptr();
  885. X    extern char *v_duplex[], *v_crio[], *v_flow[];
  886. X
  887. X    t_win = newwin(23, 80, 0, 0);
  888. X
  889. X    waddstr(t_win, "-------------------------------- ");
  890. X    wattrstr(t_win, A_BOLD, "Terminal Setup");
  891. X    waddstr(t_win, " --------------------------------");
  892. X    mvwprintw(t_win, 4, 22, "1) Hot key ................ %d", param->hot);
  893. X    mvwprintw(t_win, 6, 22, "2) ASCII version of hot ... %s", param->ascii_hot);
  894. X    mvwprintw(t_win, 9, 22, "3) Duplex ................. %s", param->d_duplex);
  895. X    mvwprintw(t_win, 11, 22, "4) Flow control ........... %s", param->flow);
  896. X    mvwprintw(t_win, 13, 22, "5) CR translation (in) .... %s", param->cr_in);
  897. X    mvwprintw(t_win, 15, 22, "6) CR translation (out) ... %s", param->cr_out);
  898. X    mvwprintw(t_win, 19, 0, "--------------------------------------------------------------------------------");
  899. X    mvwattrstr(t_win, 20, 0, A_BOLD, "OPTION ==> ");
  900. X    mvwaddstr(t_win, 20, 60, "Press ESC to return");
  901. X    wmove(t_win, 20, 12);
  902. X    touchwin(t_win);
  903. X    wrefresh(t_win);
  904. X                    /* get the option number */
  905. X    ret_code = 0;
  906. X    while ((i = get_num(t_win, 1)) != -1) {
  907. X        switch(i) {
  908. X            case 1:
  909. X                if ((num = num_prompt(t_win, 4, 50, "Hot key", "decimal code for the hot key")) != -1) {
  910. X                    param->hot = num;
  911. X                    ret_code = 1;
  912. X                }    
  913. X                break;
  914. X            case 2:
  915. X                if ((ans = str_prompt(t_win, 6, 50, "ASCII version of hot key", "(printable version)")) != NULL) {
  916. X                    free_ptr(param->ascii_hot);
  917. X                    param->ascii_hot = strdup(ans);
  918. X                    ret_code = 1;
  919. X                }    
  920. X                break;
  921. X            case 3:
  922. X                if ((ans = menu_prompt(t_win, 9, 50, "Duplex", v_duplex)) != NULL ) {
  923. X                    free_ptr(param->d_duplex);
  924. X                    param->d_duplex = strdup(ans);
  925. X                    ret_code = 1;
  926. X                }
  927. X                break;
  928. X            case 4:
  929. X                if ((ans = menu_prompt(t_win, 11, 50, "Flow control", v_flow)) != NULL ) {
  930. X                    free_ptr(param->flow);
  931. X                    param->flow = strdup(ans);
  932. X                    ret_code = 1;
  933. X                }
  934. X                break;
  935. X            case 5:
  936. X                if ((ans = menu_prompt(t_win, 13, 50, "CR translation (in)", v_crio)) != NULL ) {
  937. X                    free_ptr(param->cr_in);
  938. X                    param->cr_in = strdup(ans);
  939. X                    ret_code = 1;
  940. X                }
  941. X                break;
  942. X            case 6:
  943. X                if ((ans = menu_prompt(t_win, 15, 50, "CR translation (out)", v_crio)) != NULL ) {
  944. X                    free_ptr(param->cr_out);
  945. X                    param->cr_out = strdup(ans);
  946. X                    ret_code = 1;
  947. X                }
  948. X                break;
  949. X            default:
  950. X                beep();
  951. X        }
  952. X        mvwaddch(t_win, 20, 12, ' ');
  953. X        clear_line(t_win, 21, 0, 0);
  954. X        clear_line(t_win, 22, 0, 0);
  955. X        wmove(t_win, 20, 12);
  956. X        wrefresh(t_win);
  957. X    }
  958. X    delwin(t_win);
  959. X    return(ret_code);
  960. X}
  961. SHAR_EOF
  962. if test 2743 -ne "`wc -c < 's_term.c'`"
  963. then
  964.     echo shar: "error transmitting 's_term.c'" '(should have been 2743 characters)'
  965. fi
  966. fi
  967. echo shar: "extracting 's_tty.c'" '(4775 characters)'
  968. if test -f 's_tty.c'
  969. then
  970.     echo shar: "will not over-write existing file 's_tty.c'"
  971. else
  972. sed 's/^X//' << \SHAR_EOF > 's_tty.c'
  973. X/*
  974. X * Display the tty setup, query for changes.  A return code of 1
  975. X * means something was changed.
  976. X */
  977. X
  978. X#include <stdio.h>
  979. X#include <curses.h>
  980. X#include "misc.h"
  981. X#include "modem.h"
  982. X#include "status.h"
  983. X
  984. Xint
  985. Xtty_setup()
  986. X{
  987. X    WINDOW *tt_win, *newwin();
  988. X    char *strdup(), buf[80];
  989. X    int num, i, j, ret_code;
  990. X    void disp_tty(), create_modem(), delete_modem(), error_win();
  991. X    void delete_tty();
  992. X    extern char *null_ptr;
  993. X
  994. X    tt_win = newwin(23, 80, 0, 0);
  995. X
  996. X    waddstr(tt_win, "----------------------------------- ");
  997. X    wattrstr(tt_win, A_BOLD, "TTY Setup");
  998. X    waddstr(tt_win, " ----------------------------------");
  999. X    mvwaddstr(tt_win, 2, 22, "TTY name");
  1000. X    mvwaddstr(tt_win, 2, 37, "Modem name");
  1001. X    mvwaddstr(tt_win, 2, 51, "Maximum baud");
  1002. X                    /* display the current tty list */
  1003. X    disp_tty(tt_win);
  1004. X                    /* prompt for options */
  1005. X    mvwprintw(tt_win, 15, 20, "%d) Add a TTY entry", NUM_TTY+1);
  1006. X    mvwprintw(tt_win, 16, 20, "%d) Delete a TTY entry", NUM_TTY+2);
  1007. X    mvwprintw(tt_win, 19, 0, "--------------------------------------------------------------------------------");
  1008. X    mvwattrstr(tt_win, 20, 0, A_BOLD, "OPTION ==> ");
  1009. X    mvwaddstr(tt_win, 20, 60, "Press ESC to return");
  1010. X    wmove(tt_win, 20, 12);
  1011. X    touchwin(tt_win);
  1012. X    wrefresh(tt_win);
  1013. X                    /* get the option number */
  1014. X    ret_code = 0;
  1015. X    while ((i = get_num(tt_win, 2)) != -1) {
  1016. X                    /* if beyond t_entries, fake it */
  1017. X        if (i>modem->t_entries && i<=NUM_TTY)
  1018. X            i=999;
  1019. X                    /* change an entry  */
  1020. X        if (i>=1 && i<=NUM_TTY) {
  1021. X            if (tty_prompt(tt_win, i-1))
  1022. X                break;
  1023. X                    /* requires modem update ? */
  1024. X            create_modem(modem->tname[i-1]);
  1025. X            delete_modem();
  1026. X
  1027. X            ret_code++;
  1028. X        }
  1029. X                    /* add a entry */
  1030. X        if (i == NUM_TTY+1) {
  1031. X            if (modem->t_entries == NUM_TTY) {
  1032. X                sprintf(buf, "'%s'", status->m_path);
  1033. X                error_win(0, "No empty TTY slots in", buf);
  1034. X                continue;
  1035. X            }
  1036. X                    /* prompt for info */
  1037. X            j = modem->t_entries;
  1038. X            if (tty_prompt(tt_win, j))
  1039. X                break;
  1040. X                    /* add modem entry ? */
  1041. X            modem->t_entries++;
  1042. X            create_modem(modem->tname[j]);
  1043. X
  1044. X            ret_code++;
  1045. X        }
  1046. X                    /* delete an entry */
  1047. X        if (i == NUM_TTY+2) {
  1048. X            mvwaddstr(tt_win, 21, 0, "Entry number to delete: ");
  1049. X            wrefresh(tt_win);
  1050. X            while ((num = get_num(tt_win, 4)) != -1) {
  1051. X                    /* valid range */
  1052. X                if (!num || num>modem->t_entries) {
  1053. X                    beep();
  1054. X                    mvwaddstr(tt_win, 21, 24, "   ");
  1055. X                    wrefresh(tt_win);
  1056. X                    continue;
  1057. X                }
  1058. X                delete_tty(num-1);
  1059. X                delete_modem();
  1060. X
  1061. X                    /* show the new list */
  1062. X                disp_tty(tt_win);
  1063. X                ret_code = 1;
  1064. X            }
  1065. X
  1066. X        }
  1067. X        if (i == 0 || i>NUM_TTY+2)
  1068. X            beep();
  1069. X        mvwaddstr(tt_win, 20, 12, "  ");
  1070. X        clear_line(tt_win, 21, 0, 0);
  1071. X        clear_line(tt_win, 22, 0, 0);
  1072. X        wmove(tt_win, 20, 12);
  1073. X        wrefresh(tt_win);
  1074. X    }
  1075. X    delwin(tt_win);
  1076. X    return(ret_code);
  1077. X}
  1078. X
  1079. X/*
  1080. X * Display the current tty list.  No scrolling yet, so if your NUM_TTY is
  1081. X * greater than ten, this routine will need some work.
  1082. X */
  1083. X
  1084. Xvoid
  1085. Xdisp_tty(win)
  1086. XWINDOW *win;
  1087. X{
  1088. X    int i;
  1089. X
  1090. X    for (i=0; i<NUM_TTY; i++)
  1091. X        mvwprintw(win, i+4, 20, "%2d) %-14.14s %-14.14s  %d\n",
  1092. X         i+1, modem->tty[i], modem->tname[i], modem->mbaud[i]);
  1093. X    return;
  1094. X}
  1095. X
  1096. X/*
  1097. X * Prompt the user for the TTY database info.  A return code of 1 means a
  1098. X * user abort.  The second argument is the zero based index.
  1099. X */
  1100. X
  1101. Xtty_prompt(win, i)
  1102. XWINDOW *win;
  1103. Xint i;
  1104. X{
  1105. X    char *ans, *temp_tty, *temp_tname, *str_prompt(), *menu_prompt();
  1106. X    extern char *v_baud[];
  1107. X    void free_ptr();
  1108. X                    /* get temp tty */
  1109. X    if ((ans = str_prompt(win, i+4, 24, "TTY name", NULL)) == NULL)
  1110. X        return(1);
  1111. X
  1112. X    temp_tty = strdup(ans);
  1113. X    clear_line(win, 21, 0, 0);
  1114. X
  1115. X                    /* get temp tname */
  1116. X    if ((ans = str_prompt(win, i+4, 39, "Modem name", NULL)) == NULL)
  1117. X        return(1);
  1118. X
  1119. X    temp_tname = strdup(ans);
  1120. X    clear_line(win, 21, 0, 0);
  1121. X    
  1122. X                    /* get maximum baud */
  1123. X    if ((ans = menu_prompt(win, i+4, 55, "Maximum baud", v_baud)) == NULL)
  1124. X        return(1);
  1125. X
  1126. X    wrefresh(win);
  1127. X                    /* store 'em for real */
  1128. X    free_ptr(modem->tty[i]);
  1129. X    free_ptr(modem->tname[i]);
  1130. X
  1131. X    modem->tty[i] = strdup(temp_tty);
  1132. X    modem->tname[i] = strdup(temp_tname);
  1133. X    modem->mbaud[i] = atoi(ans);
  1134. X
  1135. X    free_ptr(temp_tty);
  1136. X    free_ptr(temp_tname);
  1137. X    return(0);
  1138. X}
  1139. X
  1140. X/*
  1141. X * Delete a tty entry.  Since the list must be contiguous, we collapse the
  1142. X * list to cover the hole we made.
  1143. X */
  1144. X
  1145. Xvoid
  1146. Xdelete_tty(i)
  1147. Xint i;
  1148. X{
  1149. X    int j;
  1150. X    char *strdup();
  1151. X    void free_ptr();
  1152. X    extern char *null_ptr;
  1153. X                    /* collapse the list */
  1154. X    for (j=i; j<modem->t_entries-1; j++) {
  1155. X        free_ptr(modem->tty[j]);
  1156. X        free_ptr(modem->tname[j]);
  1157. X        modem->tty[j] = strdup(modem->tty[j+1]);
  1158. X        modem->tname[j] = strdup(modem->tname[j+1]);
  1159. X        modem->mbaud[j] = modem->mbaud[j+1];
  1160. X    }
  1161. X    j = modem->t_entries-1;
  1162. X                    /* zap the entry */
  1163. X    free_ptr(modem->tty[j]);
  1164. X    free_ptr(modem->tname[j]);
  1165. X    modem->tty[j] = null_ptr;
  1166. X    modem->tname[j] = null_ptr;
  1167. X    modem->mbaud[j] = 0;
  1168. X                    /* update the count */
  1169. X    modem->t_entries--;
  1170. X    if (modem->t_cur >= modem->t_entries)
  1171. X        modem->t_cur = -1;
  1172. X    return;
  1173. X}
  1174. SHAR_EOF
  1175. if test 4775 -ne "`wc -c < 's_tty.c'`"
  1176. then
  1177.     echo shar: "error transmitting 's_tty.c'" '(should have been 4775 characters)'
  1178. fi
  1179. fi
  1180. echo shar: "extracting 'screen.c'" '(1421 characters)'
  1181. if test -f 'screen.c'
  1182. then
  1183.     echo shar: "will not over-write existing file 'screen.c'"
  1184. else
  1185. sed 's/^X//' << \SHAR_EOF > 'screen.c'
  1186. X/*
  1187. X * Routines to read and copy the virtual screen image file.
  1188. X */
  1189. X
  1190. X#define MAX_COL    128
  1191. X
  1192. X#include <stdio.h>
  1193. X#include <curses.h>
  1194. X#include "param.h"
  1195. X#include "status.h"
  1196. X
  1197. X/*
  1198. X * Do a screen dump.  Actually, the screen is already dumped, all we
  1199. X * do is copy the file.
  1200. X */
  1201. X
  1202. Xvoid
  1203. Xscreen_dump()
  1204. X{
  1205. X    FILE *fp_in, *fp_out;
  1206. X    char buf[MAX_COL+2];
  1207. X    void error_win();
  1208. X                    /* not guaranteed to exist yet */
  1209. X    if (!(fp_in = fopen(status->vs_path, "r")))
  1210. X        return;
  1211. X                    /* open for append */
  1212. X    if (!(fp_out = fopen(param->dumpfile, "a"))) {
  1213. X        fclose(fp_in);
  1214. X        sprintf(buf, "'%s' for write", param->dumpfile);
  1215. X        error_win(0, "Can't open screen dump file", buf);
  1216. X        return;
  1217. X    }
  1218. X                    /* skip the x, y coordinates */
  1219. X    fgets(buf, 10, fp_in);
  1220. X
  1221. X    while (fgets(buf, MAX_COL+2, fp_in) != NULL)
  1222. X        fputs(buf, fp_out);
  1223. X
  1224. X    fclose(fp_in);
  1225. X    fclose(fp_out);
  1226. X
  1227. X    return;
  1228. X}
  1229. X
  1230. X/*
  1231. X * Read the virtual screen file and paint its contents to the
  1232. X * stdscr with curses.  Leave the cursor where it belongs.
  1233. X */
  1234. X
  1235. Xvoid
  1236. Xload_vs()
  1237. X{
  1238. X    FILE *fp;
  1239. X    int row, col, i;
  1240. X    char buf[MAX_COL+2];
  1241. X                    /* not guaranteed to exist yet */
  1242. X    if (!(fp = fopen(status->vs_path, "r")))
  1243. X        return;
  1244. X                    /* get the x, y coordinates */
  1245. X    fgets(buf, 10, fp);
  1246. X    sscanf(buf, "%d,%d\n", &row, &col);
  1247. X    
  1248. X    clearok(stdscr, TRUE);
  1249. X    i = 0;
  1250. X    while (fgets(buf, MAX_COL+2, fp) != NULL) {
  1251. X        buf[COLS] = NULL;
  1252. X        mvaddstr(i++, 0, buf);
  1253. X    }
  1254. X    move(row, col);
  1255. X    refresh();
  1256. X    clearok(stdscr, FALSE);
  1257. X
  1258. X    fclose(fp);
  1259. X    return;
  1260. X}
  1261. SHAR_EOF
  1262. if test 1421 -ne "`wc -c < 'screen.c'`"
  1263. then
  1264.     echo shar: "error transmitting 'screen.c'" '(should have been 1421 characters)'
  1265. fi
  1266. fi
  1267. echo shar: "extracting 'st_line.c'" '(1815 characters)'
  1268. if test -f 'st_line.c'
  1269. then
  1270.     echo shar: "will not over-write existing file 'st_line.c'"
  1271. else
  1272. sed 's/^X//' << \SHAR_EOF > 'st_line.c'
  1273. X/*
  1274. X * Display the status line.  Up to now, we've never really cared how
  1275. X * large the physical screen was... but now we want the status line
  1276. X * on the bottom.
  1277. X */
  1278. X
  1279. X#include <curses.h>
  1280. X#include "dial_dir.h"
  1281. X#include "misc.h"
  1282. X#include "modem.h"
  1283. X#include "param.h"
  1284. X#include "status.h"
  1285. X
  1286. Xvoid
  1287. Xstatus_line(message)
  1288. Xchar *message;
  1289. X{
  1290. X    WINDOW *sl_win, *newwin();
  1291. X    int d, x, y;
  1292. X    static char *dn[2] = {"FDX", "HDX"};
  1293. X    static char *ln[2] = {"LOG OFF", "LOG ON"};
  1294. X    static char *pn[2] = {"PTR OFF", "PTR ON "};
  1295. X    char buf[80], field_one[15], *cur_tty;
  1296. X    extern int xmc;
  1297. X
  1298. X    /*
  1299. X     * Sometimes curses() doesn't remember where the cursor is on
  1300. X     * the screen, so we move it to the opposite corner to guarantee
  1301. X     * that the status line is on the bottom.
  1302. X     */
  1303. X    getyx(stdscr, y, x);
  1304. X    move(0, COLS-1);
  1305. X    refresh();
  1306. X
  1307. X    sl_win = newwin(1, 80, LINES-1, 0);
  1308. X                    /* duplex message */
  1309. X    d = 0;
  1310. X    if (dir->duplex[dir->d_cur] == 'H')
  1311. X        d = 1;
  1312. X                    /* the current tty */
  1313. X    cur_tty = "No TTY";
  1314. X    if (modem->t_cur != -1)
  1315. X        cur_tty = modem->tty[modem->t_cur];
  1316. X    
  1317. X    /*
  1318. X     * The philosophy is:  If you press a command sequence that
  1319. X     * doesn't generate a window on the screen, then show the user
  1320. X     * what's going on in the status line.
  1321. X     */
  1322. X    if (message == NULL)
  1323. X        sprintf(field_one, " %4.4s-0 HELP  ", param->ascii_hot);
  1324. X    else
  1325. X        sprintf(field_one, " %-13.13s", message);
  1326. X
  1327. X    sprintf(buf, "%s | %-9.9s| %s | %5d %c%d%d | %-7.7s | %-7.7s | %-5.5s| %-5.5s",
  1328. X     field_one, cur_tty, dn[d], dir->baud[dir->d_cur],
  1329. X     dir->parity[dir->d_cur], dir->dbits[dir->d_cur],
  1330. X     dir->sbits[dir->d_cur], ln[status->log], pn[status->print],
  1331. X     param->cr_in, param->cr_out);
  1332. X    
  1333. X    if (xmc > 0) {
  1334. X        touchwin(sl_win);
  1335. X        werase(sl_win);
  1336. X        wrefresh(sl_win);
  1337. X    }
  1338. X    wattrstr(sl_win, A_STANDOUT, buf);
  1339. X    wrefresh(sl_win);
  1340. X                    /* go ahead and delete it now */
  1341. X    delwin(sl_win);
  1342. X    move(y, x);
  1343. X    return;
  1344. X}
  1345. SHAR_EOF
  1346. if test 1815 -ne "`wc -c < 'st_line.c'`"
  1347. then
  1348.     echo shar: "error transmitting 'st_line.c'" '(should have been 1815 characters)'
  1349. fi
  1350. fi
  1351. echo shar: "extracting 'strings.c'" '(1349 characters)'
  1352. if test -f 'strings.c'
  1353. then
  1354.     echo shar: "will not over-write existing file 'strings.c'"
  1355. else
  1356. sed 's/^X//' << \SHAR_EOF > 'strings.c'
  1357. X/*
  1358. X * Miscellaneous string routines.
  1359. X */
  1360. X
  1361. X#include <stdio.h>
  1362. X
  1363. X/*
  1364. X * Do a fancy string copy.  If NULL, return null.  If pointer to NULL, then
  1365. X * return the special 'null_ptr' variable.  If a normal copy, allocate the
  1366. X * memory first.
  1367. X */
  1368. X
  1369. Xchar *
  1370. Xstrdup(str)
  1371. Xchar *str;
  1372. X{
  1373. X    char *ret, *malloc(), *strcpy();
  1374. X    extern char *null_ptr;
  1375. X
  1376. X    if (str == NULL)
  1377. X        return(NULL);
  1378. X                    /* if pointer to null */
  1379. X    if (*str == NULL)
  1380. X        return(null_ptr);
  1381. X
  1382. X    ret = malloc((unsigned int) strlen(str)+1);
  1383. X    strcpy(ret, str);
  1384. X    return(ret);
  1385. X}
  1386. X
  1387. X/*
  1388. X * Perform the free(2) function, but check for NULL and the special
  1389. X * 'null_ptr' variable first.
  1390. X */
  1391. X
  1392. Xvoid
  1393. Xfree_ptr(str)
  1394. Xchar *str;
  1395. X{
  1396. X    extern char *null_ptr;
  1397. X    void free();
  1398. X
  1399. X    if (str != NULL && (long) str != (long) null_ptr)
  1400. X        free(str);
  1401. X    return;
  1402. X}
  1403. X
  1404. X/*
  1405. X * This routine is similar to strtok(3).  But our version handles null
  1406. X * strings and takes a single separator character as an argument.
  1407. X * Returns a NULL on end of string or error.
  1408. X */
  1409. X
  1410. Xchar *
  1411. Xstr_tok(str, c)
  1412. Xchar *str, c;
  1413. X{
  1414. X    char *strchr();
  1415. X    static char *ptr, *sep;
  1416. X    extern char *null_ptr;
  1417. X                    /* start at beginning */
  1418. X    if (str != NULL)
  1419. X        ptr = str;
  1420. X    else
  1421. X        ptr = sep;
  1422. X                    /* at the end ? */
  1423. X    if (*ptr == NULL)
  1424. X        return(NULL);
  1425. X                    /* no separator ? */
  1426. X    if (!(sep = strchr(ptr, c)))
  1427. X        return(NULL);
  1428. X                    /* zap the sep, move past it */
  1429. X    *sep = NULL;
  1430. X    sep++;
  1431. X
  1432. X    return(ptr);
  1433. X}
  1434. SHAR_EOF
  1435. if test 1349 -ne "`wc -c < 'strings.c'`"
  1436. then
  1437.     echo shar: "error transmitting 'strings.c'" '(should have been 1349 characters)'
  1438. fi
  1439. fi
  1440. echo shar: "extracting 'terminal.c'" '(8039 characters)'
  1441. if test -f 'terminal.c'
  1442. then
  1443.     echo shar: "will not over-write existing file 'terminal.c'"
  1444. else
  1445. sed 's/^X//' << \SHAR_EOF > 'terminal.c'
  1446. X/*
  1447. X * Start the terminal dialogue, fork the input routine, watch for the
  1448. X * hot key so we can execute an option.
  1449. X */
  1450. X
  1451. X#include <stdio.h>
  1452. X#include <curses.h>
  1453. X#include <signal.h>
  1454. X#ifdef UNIXPC
  1455. X#include <sys/phone.h>
  1456. X#include <fcntl.h>
  1457. X#endif /* UNIXPC */
  1458. X#include "dial_dir.h"
  1459. X#include "modem.h"
  1460. X#include "param.h"
  1461. X#include "status.h"
  1462. X
  1463. Xterminal(input_status)
  1464. Xint input_status;
  1465. X{
  1466. X    int i, k, cr_lf;
  1467. X    char c, lf=10, *strdup(), *new_dir, *change_dir();
  1468. X    void help_screen(), line_set(), native_shell(), load_vs();
  1469. X    void setup_menu(), hang_up(), input_on(), list_dir(), pexit();
  1470. X    void status_line(), free_ptr(), screen_dump(), input_off();
  1471. X
  1472. X                    /* if starting out in command mode */
  1473. X    if (!input_status)
  1474. X        status_line(NULL);
  1475. X                    /* put the terminal in raw mode */
  1476. X    resetterm();
  1477. X    cr_lf = raw_mode();
  1478. X
  1479. X    if (input_status)
  1480. X        input_on();
  1481. X
  1482. X    while(1) {
  1483. X        read(0, &c, 1);
  1484. X                    /* is it the hot key? */
  1485. X        if (c == param->hot) {
  1486. X                    /* suspend input */
  1487. X            input_status = 0;
  1488. X            if (status->pid != -1)
  1489. X                kill(status->pid, SIGINT);
  1490. X
  1491. X            /*
  1492. X             * Put in terminal in the curses mode and add
  1493. X             * the status line at the bottom.
  1494. X             */
  1495. X            fixterm();
  1496. X            status_line(NULL);
  1497. X#ifndef OLDCURSES
  1498. X            keypad(stdscr, 1);
  1499. X#endif /* OLDCURSES */
  1500. X            i = wgetch(stdscr);
  1501. X                    /* map the hot key to -1 */
  1502. X            if (i == param->hot)
  1503. X                i = -1;
  1504. X            /*
  1505. X             * Load the virtual screen from the file.  On
  1506. X             * very busy systems, the file might not "appear"
  1507. X             * fast enough for this routine to detect it.
  1508. X             * Or worse, it may contain partially written
  1509. X             * information.
  1510. X             */
  1511. X            load_vs();
  1512. X                    /* look for options */
  1513. X            k = -1;
  1514. X            switch (i) {
  1515. X                case -1:    /* 2 'hots' means send 1 */
  1516. X                    k = param->hot;
  1517. X                    break;
  1518. X                case '0':    /* help screen */
  1519. X                    help_screen(param->ascii_hot, status->fd);
  1520. X                    break;
  1521. X                case 'd':
  1522. X                case 'D':    /* dialing directory */
  1523. X                    if (dial_menu())
  1524. X                        input_status = dial_win();
  1525. X                    break;
  1526. X                case 'r':
  1527. X                case 'R':    /* redial */
  1528. X                    if (redial(status->fd))
  1529. X                        input_status = dial_win();
  1530. X                    break;
  1531. X                case 'p':
  1532. X                case 'P':    /* line settings */
  1533. X                    if (line_set_menu(status->fd)) {
  1534. X                        line_set();
  1535. X                    }
  1536. X                    break;
  1537. X                case 'x':
  1538. X                case 'X':    /* exit */
  1539. X                    pexit(status->fd);
  1540. X                    break;
  1541. X                case '4':    /* Unix gateway */
  1542. X                    native_shell();
  1543. X                    break;
  1544. X                case 'i':
  1545. X                case 'I':    /* Program info screen */
  1546. X                    info(status->fd);
  1547. X                    break;
  1548. X                case 's':    /* setup menu */
  1549. X                case 'S':
  1550. X                    setup_menu(status->fd);
  1551. X                    break;
  1552. X                case 'c':    /* clear the screen */
  1553. X                case 'C':
  1554. X                    unlink(status->vs_path);
  1555. X                    clear();
  1556. X                    clear_absolute(stdscr);
  1557. X                    break;
  1558. X                case 'b':
  1559. X                case 'B':    /* Change directory */
  1560. X                    if ((new_dir = change_dir(status->fd)) != NULL) {
  1561. X                        chdir(new_dir);
  1562. X                        free_ptr(new_dir);
  1563. X                    }
  1564. X                    break;
  1565. X                case 'e':
  1566. X                case 'E':    /* toggle duplex */
  1567. X                    if (dir->duplex[dir->d_cur] == 'F')
  1568. X                        dir->duplex[dir->d_cur] = 'H';
  1569. X                    else
  1570. X                        dir->duplex[dir->d_cur] = 'F';
  1571. X                    line_set();
  1572. X
  1573. X                        /* show changes */
  1574. X                    status_line(NULL);
  1575. X                    k = wait_key(stdscr, 2);
  1576. X                    break;
  1577. X                case 'h':
  1578. X                case 'H':    /* hang up phone */
  1579. X                    hang_up(1);
  1580. X                    input_off();
  1581. X                    break;
  1582. X                case 'l':
  1583. X                case 'L':    /* toggle printer */
  1584. X                    status->print = status->print ? 0 : 1;
  1585. X                    if (status->pid != -1)
  1586. X                        kill(status->pid, SIGUSR2);
  1587. X
  1588. X                        /* show changes */
  1589. X                    status_line(NULL);
  1590. X                    k = wait_key(stdscr, 2);
  1591. X                    break;
  1592. X                case '3':    /* toggle CR  CR/LF */
  1593. X                    if (!strcmp(param->cr_in, "CR"))
  1594. X                        param->cr_in = strdup("CR/LF");
  1595. X                    else
  1596. X                        param->cr_in = strdup("CR");
  1597. X                    input_off();
  1598. X                    input_status = 1;
  1599. X
  1600. X                        /* show changes */
  1601. X                    status_line(NULL);
  1602. X                    k = wait_key(stdscr, 2);
  1603. X                    break;
  1604. X                case '7':    /* break key */
  1605. X                    if (status->fd != -1)
  1606. X                        ioctl(status->fd, TCSBRK, 0);
  1607. X
  1608. X                    status_line("   break");
  1609. X                    break;
  1610. X#ifndef OLDCURSES
  1611. X                case KEY_UP:
  1612. X#endif /* OLDCURSES */
  1613. X                case 'u':
  1614. X                case 'U':    /* send files */
  1615. X                    input_status = xfer_menu(1);
  1616. X                    break;
  1617. X#ifndef OLDCURSES
  1618. X                case KEY_DOWN:
  1619. X                case '\n':
  1620. X#endif /* OLDCURSES */
  1621. X                case 'n':
  1622. X                case 'N':    /* receive files */
  1623. X                    input_status = xfer_menu(0);
  1624. X                    break;
  1625. X                case 'f':
  1626. X                case 'F':    /* list directory */
  1627. X                    list_dir(status->fd);
  1628. X                    break;
  1629. X                case 'g':    /* screen dump */
  1630. X                case 'G':
  1631. X                    screen_dump();
  1632. X                    status_line(" screen dump");
  1633. X                    k = wait_key(stdscr, 2);
  1634. X                    break;
  1635. X                case '1':    /* data logging */
  1636. X                    input_status = data_logging(status->fd);
  1637. X                    break;
  1638. X                case '2':    /* toggle log */
  1639. X                    if (!strcmp(status->log_path, "NOT_DEFINED")) {
  1640. X                        beep();
  1641. X                        status_line(" no log file");
  1642. X                        k = wait_key(stdscr, 2);
  1643. X                        break;
  1644. X                    }
  1645. X                    status->log = status->log ? 0 : 1;
  1646. X                    if (status->pid != -1)
  1647. X                        kill(status->pid, SIGUSR1);
  1648. X    
  1649. X                        /* show changes */
  1650. X                    status_line(NULL);
  1651. X                    k = wait_key(stdscr, 2);
  1652. X                    break;
  1653. X                default:
  1654. X                    fputc(7, stderr);
  1655. X                    break;
  1656. X            }
  1657. X
  1658. X            /*
  1659. X             * Repaint the stdscr (if we are already talking),
  1660. X             * get the terminal out of the curses mode and
  1661. X             * into the raw mode.
  1662. X             */
  1663. X            if (status->fd != -1) {
  1664. X                touchwin(stdscr);
  1665. X                refresh();
  1666. X            }
  1667. X            resetterm();
  1668. X            cr_lf = raw_mode();
  1669. X                    /* re-start input routine */
  1670. X            if (input_status)
  1671. X                input_on();
  1672. X            else {
  1673. X                    /* un-suspend (is that a word?) */
  1674. X                if (status->pid != -1)
  1675. X                    kill(status->pid, SIGINT);
  1676. X            }
  1677. X            /*
  1678. X             * If you pressed a key during one of the sleeping
  1679. X             * periods (typically the delay to see the status
  1680. X             * line change), let the keyboard value fall thru
  1681. X             * to the write() below.
  1682. X             */
  1683. X            if (k == -1)
  1684. X                continue;
  1685. X            c = k;
  1686. X        }
  1687. X        write(status->fd, &c, 1);
  1688. X                    /* map cr to cr_lf ? */
  1689. X        if (cr_lf)
  1690. X            write(status->fd, &lf, 1);
  1691. X    }
  1692. X}
  1693. X
  1694. X/*
  1695. X * Put the terminal in the raw mode.  We've divided up the responsibility
  1696. X * for the line settings options between the serial port and the tty driver
  1697. X * for the stdin and stdout.  The return code is the cr_lf mapping.
  1698. X */
  1699. X
  1700. Xint
  1701. Xraw_mode()
  1702. X{
  1703. X    int ret_code;
  1704. X    struct termio tbuf;
  1705. X
  1706. X    ioctl(0, TCGETA, &tbuf);
  1707. X
  1708. X    tbuf.c_cc[4] = 1;        /* VMIN */
  1709. X    tbuf.c_cc[5] = 0;        /* VTIME */
  1710. X    tbuf.c_iflag = 0;
  1711. X    tbuf.c_oflag = 0;
  1712. X    tbuf.c_lflag = 0;
  1713. X
  1714. X    /*
  1715. X     * Some of the output processing options have to be faked...
  1716. X     * Unfortunately, adding a LF to CR is one of them.
  1717. X     */
  1718. X    ret_code = 0;
  1719. X    if (!strcmp(param->cr_out, "CR/LF"))
  1720. X        ret_code++;
  1721. X                    /* duplex */
  1722. X    if (dir->duplex[dir->d_cur] == 'H')
  1723. X        tbuf.c_lflag = ECHO;
  1724. X
  1725. X    ioctl(0, TCSETA, &tbuf);
  1726. X    ioctl(0, TCFLSH, 2);
  1727. X    return(ret_code);
  1728. X}
  1729. X
  1730. X/*
  1731. X * Fire up the input routine...
  1732. X */
  1733. X
  1734. Xvoid
  1735. Xinput_on()
  1736. X{
  1737. X    int pid, add_lf;
  1738. X                    /* if no tty, or already on */
  1739. X    if (status->pid != -1 || status->fd == -1)
  1740. X        return;
  1741. X                    /* input cr translations */
  1742. X    add_lf = !strcmp(param->cr_in, "CR/LF");
  1743. X
  1744. X                    /* fork the input routine */
  1745. X    if (!(pid = fork()))
  1746. X        input(status->fd, add_lf, status->log, status->print,
  1747. X         LINES, COLS, status->vs_path, status->log_path);
  1748. X
  1749. X    status->pid = pid;
  1750. X    return;
  1751. X}
  1752. X
  1753. X/*
  1754. X * shut it down...
  1755. X */
  1756. X
  1757. Xvoid
  1758. Xinput_off()
  1759. X{
  1760. X    if (status->pid != -1) {
  1761. X        kill(status->pid, SIGTERM);
  1762. X        status->pid = -1;
  1763. X    }
  1764. X    return;
  1765. X}
  1766. X
  1767. X/*
  1768. X * Hang up the phone but remain in the pcomm command state.
  1769. X */
  1770. X
  1771. Xvoid
  1772. Xhang_up(verbose)
  1773. Xint verbose;
  1774. X{
  1775. X    void send_str(), status_line();
  1776. X#ifdef UNIXPC
  1777. X    char buf[20], *strcpy(), *strcat();
  1778. X#endif /* UNIXPC */
  1779. X
  1780. X                    /* anything to hang up? */
  1781. X    if (modem->m_cur == -1)
  1782. X        return;
  1783. X
  1784. X    if (verbose)
  1785. X        status_line("disconnecting");
  1786. X                    /* special case for OBM */
  1787. X#ifdef UNIXPC
  1788. X    if (!strcmp(modem->mname[modem->m_cur], "OBM")) {
  1789. X        ioctl(status->fd, PIOCDISC);
  1790. X        /*
  1791. X         * The PIOCDISC ioctl prevents writes on the file descriptor!
  1792. X         * No other phone(7) ioctl can fix it...  Whatever it does, it
  1793. X         * seems to escape detection with PIOCGETA and TCGETA.  The
  1794. X         * best I can do is close the descriptor and start over.
  1795. X         */
  1796. X        close(status->fd);
  1797. X        strcpy(buf, "/dev/");
  1798. X        strcat(buf, modem->tty[modem->t_cur]);
  1799. X        status->fd = open(buf, O_RDWR|O_NDELAY);
  1800. X        fcntl(status->fd, F_SETFL, fcntl(status->fd, F_GETFL, 0) & ~O_NDELAY);
  1801. X    }
  1802. X    else
  1803. X#endif /* UNIXPC */
  1804. X        send_str(modem->hangup[modem->m_cur]);
  1805. X
  1806. X    if (verbose)
  1807. X        status_line(NULL);
  1808. X    return;
  1809. X}
  1810. SHAR_EOF
  1811. if test 8039 -ne "`wc -c < 'terminal.c'`"
  1812. then
  1813.     echo shar: "error transmitting 'terminal.c'" '(should have been 8039 characters)'
  1814. fi
  1815. fi
  1816. echo shar: "extracting 'x_ascii.c'" '(5950 characters)'
  1817. if test -f 'x_ascii.c'
  1818. then
  1819.     echo shar: "will not over-write existing file 'x_ascii.c'"
  1820. else
  1821. sed 's/^X//' << \SHAR_EOF > 'x_ascii.c'
  1822. X/*
  1823. X * Transfer a file using just XON/XOFF flow control.  Currently limited to
  1824. X * 7 bit ASCII codes. (If this causes too much trouble, I'll change it).
  1825. X */
  1826. X
  1827. X#include <stdio.h>
  1828. X#include <fcntl.h>
  1829. X#include <curses.h>
  1830. X#include <signal.h>
  1831. X#include "param.h"
  1832. X#include "status.h"
  1833. X
  1834. Xvoid
  1835. Xxfer_ascii(list, up)
  1836. Xchar *list;
  1837. Xint up;
  1838. X{
  1839. X    int cr_lf;
  1840. X    char *file, *strtok();
  1841. X    void send_ascii(), rcv_ascii(), line_set(), status_line();
  1842. X    unsigned int sleep();
  1843. X
  1844. X                    /* only one file from list */
  1845. X    file = strtok(list, "     ");
  1846. X
  1847. X    cr_lf = ascii_mode(up);
  1848. X    if (up) {
  1849. X                    /* un-suspend the input routine */
  1850. X        if (status->pid != -1)
  1851. X            kill(status->pid, SIGINT);
  1852. X
  1853. X        send_ascii(file, cr_lf);
  1854. X                    /* re-suspend the input routine */
  1855. X        if (status->pid != -1)
  1856. X            kill(status->pid, SIGINT);
  1857. X    }
  1858. X    else
  1859. X        rcv_ascii(file, cr_lf);
  1860. X
  1861. X    /*
  1862. X     * Restoring the tty modes is easier than setting them... The
  1863. X     * fixterm() and line_set() routines fix most of the damage.
  1864. X     */
  1865. X    fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) & ~O_NDELAY);
  1866. X    fixterm();
  1867. X    line_set();
  1868. X    sleep(1);
  1869. X
  1870. X    status_line("xfer complete");
  1871. X    sleep(2);
  1872. X    return;
  1873. X}
  1874. X
  1875. X/*
  1876. X * Put the tty line in a mode suitable for the ASCII transfer.  Puts the
  1877. X * terminal in the raw, non-blocking mode.  Returns the status of the
  1878. X * cr_lf parameter flag.
  1879. X */
  1880. X
  1881. Xint
  1882. Xascii_mode(up)
  1883. Xint up;
  1884. X{
  1885. X    int cr_lf;
  1886. X    struct termio tbuf;
  1887. X    void input_off();
  1888. X
  1889. X    ioctl(status->fd, TCGETA, &tbuf);
  1890. X    tbuf.c_oflag = 0;
  1891. X                    /* flow control & 8th bit stripping */
  1892. X    if (up) {
  1893. X        tbuf.c_iflag = (ISTRIP|IXON|IXANY);
  1894. X
  1895. X                    /* use NL delays if no CR */
  1896. X        if (!strcmp(param->cr_up, "STRIP"))
  1897. X            tbuf.c_oflag = (OPOST|ONLRET);
  1898. X
  1899. X                    /* CR delay times */
  1900. X        switch (param->cr_delay) {
  1901. X            case 0:
  1902. X                tbuf.c_oflag = 0;
  1903. X                break;
  1904. X            case 100:
  1905. X                tbuf.c_oflag |= (OPOST|CR2);
  1906. X                break;
  1907. X            case 150:
  1908. X                tbuf.c_oflag |= (OPOST|CR3);
  1909. X                break;
  1910. X        }
  1911. X    }
  1912. X                    /* if down loading */
  1913. X    else {
  1914. X        tbuf.c_iflag = (ISTRIP|IXOFF);
  1915. X                    /* kill the input routine */
  1916. X        input_off();
  1917. X    }
  1918. X
  1919. X    ioctl(status->fd, TCSETA, &tbuf);
  1920. X    ioctl(status->fd, TCFLSH, 2);
  1921. X                    /* out of curses mode */
  1922. X    resetterm();
  1923. X    cr_lf = raw_mode();
  1924. X                    /* non-blocking mode */
  1925. X    fcntl(0, F_SETFL, fcntl(0, F_GETFL, 0) | O_NDELAY);
  1926. X    return(cr_lf);
  1927. X}
  1928. X    
  1929. X/*
  1930. X * Send a file.  The local echo option is independent of the duplex option,
  1931. X * and would very rarely be used since the characters are most likely
  1932. X * being echoed on the screen anyway.
  1933. X */
  1934. X
  1935. Xvoid
  1936. Xsend_ascii(file, cr_lf)
  1937. Xchar *file;
  1938. Xint cr_lf;
  1939. X{
  1940. X    FILE *fp;
  1941. X    int i, j, strip_cr, strip_lf, add_cr, add_lf, expand, last;
  1942. X    int lecho, pace;
  1943. X    unsigned int sleep();
  1944. X    unsigned char c;
  1945. X                    /* permission already checked */
  1946. X    if (!(fp = fopen(file, "r")))
  1947. X        return;
  1948. X                    /* ASCII transfer options */
  1949. X    strip_cr = !strcmp(param->cr_up, "STRIP");
  1950. X    add_lf = !strcmp(param->cr_up, "ADD LF");
  1951. X    strip_lf = !strcmp(param->lf_up, "STRIP");
  1952. X    add_cr = !strcmp(param->lf_up, "ADD CR");
  1953. X    expand = !strcmp(param->expand, "YES");
  1954. X    lecho = !strcmp(param->lecho, "YES");
  1955. X    pace = !strcmp(param->pace, "YES");
  1956. X
  1957. X    last = 0;
  1958. X    while ((i = fgetc(fp)) != EOF) {
  1959. X                    /* any keyboard activity? */
  1960. X        switch(j = getchar()) {
  1961. X            case -1:    /* no key was pressed */
  1962. X                break;
  1963. X            case 27:    /* ESC key for abort */
  1964. X                fclose(fp);
  1965. X                ioctl(status->fd, TCFLSH, 2);
  1966. X                return;
  1967. X            default:    /* send the char */
  1968. X                c = j;
  1969. X                putc_line(c);
  1970. X                if (c == 13 && cr_lf)
  1971. X                    putc_line(10);
  1972. X                break;
  1973. X        }
  1974. X        c = i;
  1975. X                    /* expand blank lines */
  1976. X        if (expand && last == 10 && c == 10)
  1977. X            putc_line(' ');
  1978. X        last = c;
  1979. X
  1980. X                    /* CR translations */
  1981. X        if (c == 13 && strip_cr)
  1982. X            continue;
  1983. X        if (c == 13 && add_lf) {
  1984. X            putc_line(c);
  1985. X            putc_line(10);
  1986. X            continue;
  1987. X        }
  1988. X                    /* LF translations */
  1989. X        if (c == 10 && strip_lf)
  1990. X            continue;
  1991. X        if (c == 10 && add_cr) {
  1992. X            putc_line(13);
  1993. X            putc_line(c);
  1994. X            continue;
  1995. X        }
  1996. X        putc_line(c);
  1997. X        /*
  1998. X         * There's really no mechanism for delaying characters
  1999. X         * going to the output, so we fake it by waiting for
  2000. X         * each character to clear the I/O buffer.
  2001. X         */
  2002. X        if (pace)
  2003. X            ioctl(status->fd, TCSBRK, 1);
  2004. X        if (lecho)
  2005. X            write(1, (char *) &c, 1);
  2006. X    }
  2007. X    sleep(1);
  2008. X    ioctl(status->fd, TCSBRK, 1);
  2009. X    fclose(fp);
  2010. X    return;
  2011. X}
  2012. X
  2013. X/*
  2014. X * Receive a file.  The timer is used to end the transfer.  This is not
  2015. X * that much different from the data logging option.  The use of getc_line()
  2016. X * and non-blocking input makes it seem like full duplex, but it's not.
  2017. X * Beware that while the timer is active the keyboard is deaf.  Input is
  2018. X * NOT loaded into the virtual screen!!
  2019. X */
  2020. X
  2021. Xvoid
  2022. Xrcv_ascii(file, cr_lf)
  2023. Xchar *file;
  2024. Xint cr_lf;
  2025. X{
  2026. X    FILE *fp;
  2027. X    int i, strip_cr, strip_lf, add_cr, add_lf, got_first;
  2028. X    unsigned int delay;
  2029. X    unsigned char c;
  2030. X                    /* permission already checked */
  2031. X    if (!(fp = fopen(file, "w")))
  2032. X        return;
  2033. X                    /* ASCII transfer options */
  2034. X    strip_cr = !strcmp(param->cr_dn, "STRIP");
  2035. X    add_lf = !strcmp(param->cr_dn, "ADD LF");
  2036. X    strip_lf = !strcmp(param->lf_dn, "STRIP");
  2037. X    add_cr = !strcmp(param->lf_dn, "ADD CR");
  2038. X
  2039. X    got_first = 0;
  2040. X    delay = 1;
  2041. X    while (1) {
  2042. X                    /* keyboard activity */
  2043. X        switch (i = getchar()) {
  2044. X            case -1:    /* no key was pressed */
  2045. X                break;
  2046. X            case 27:    /* ESC key */
  2047. X                fclose(fp);
  2048. X                return;
  2049. X            default:    /* send it */
  2050. X                c = i;
  2051. X                putc_line(c);
  2052. X                if (c == 13 && cr_lf)
  2053. X                    putc_line(10);
  2054. X                break;
  2055. X        }
  2056. X                    /* read a character */
  2057. X        if ((i = getc_line(delay)) == -1) {
  2058. X            /*
  2059. X             * The transfer timeout is not activated until the
  2060. X             * first character is received.  Until then, it polls
  2061. X             * the line for one second and loops backs for
  2062. X             * keyboard input.
  2063. X             */
  2064. X            if (got_first) {
  2065. X                fclose(fp);
  2066. X                return;
  2067. X            }
  2068. X            continue;
  2069. X        }
  2070. X        got_first = 1;
  2071. X        delay = param->timer;
  2072. X        c = i & 0177;
  2073. X                    /* display it on the screen */
  2074. X        write(1, (char *) &c, 1);
  2075. X                    /* CR translations */
  2076. X        if (c == 13 && strip_cr)
  2077. X            continue;
  2078. X        if (c == 13 && add_lf) {
  2079. X            fputc((char) c, fp);
  2080. X            fputc(10, fp);
  2081. X            continue;
  2082. X        }
  2083. X                    /* LF translations */
  2084. X        if (c == 10 && strip_lf)
  2085. X            continue;
  2086. X        if (c == 10 && add_cr) {
  2087. X            fputc(13, fp);
  2088. X            fputc((char) c, fp);
  2089. X            continue;
  2090. X        }
  2091. X        fputc((char) c, fp);
  2092. X    }
  2093. X}
  2094. SHAR_EOF
  2095. if test 5950 -ne "`wc -c < 'x_ascii.c'`"
  2096. then
  2097.     echo shar: "error transmitting 'x_ascii.c'" '(should have been 5950 characters)'
  2098. fi
  2099. fi
  2100. exit 0
  2101. #    End of shell archive
  2102.  
  2103.  
  2104.